#ifndef THREAD_SEARCH_THREAD_H
#define THREAD_SEARCH_THREAD_H

#include <wx/thread.h>
#include <wx/dir.h>
#include <wx/arrstr.h>
#include "ThreadSearchFindData.h"
#include "ThreadSearch.h"
#include "ThreadSearchView.h"

class wxString;
class M_Code_Project;
class ProjectBuildTarget;
class cbStyledTextCtrl;
class TextFileSearcher;
class ThreadSearchView;
class ThreadSearchThread;

class ThreadSearchThread : public wxThread, public wxDirTraverser {
  public:
    ThreadSearchThread( ThreadSearchView* pThreadSearchView, const ThreadSearchFindData& findData );
    ~ThreadSearchThread();
    void OnExit();
  protected:
    void *Entry();
  private:
    wxDirTraverseResult OnDir( const wxString& dirName );
    wxDirTraverseResult OnFile( const wxString& fileName );
    void FindInFile( const wxString& path );
    static bool AddNewItem( wxSortedArrayString& sortedArrayString, const wxString& newItem );
    void AddProjectFiles( wxSortedArrayString& sortedArrayString, M_Code_Project& project );
    void AddTargetFiles( wxSortedArrayString& sortedArrayString, ProjectBuildTarget& target );
    ThreadSearchView*    m_pThreadSearchView;
    ThreadSearchFindData m_FindData;
    wxDirTraverseResult  m_DefaultDirResult;
    wxArrayString        m_LineTextArray;
    wxArrayString        m_Masks;
    wxSortedArrayString  m_FilePaths;
    TextFileSearcher*    m_pTextFileSearcher;
    bool m_ShowFileMissingError;
    bool m_ShowCantOpenFileError;
    std::set<wxString>      m_VisitedDirs;
};
#endif
